home *** CD-ROM | disk | FTP | other *** search
-
- /*
- File: ListOfLongs.h
-
- Contains: TListOfLongs interface
-
- Developed by:
-
- Paul G Smith (commstalk hq & Full Moon Software, Inc)
-
- you can leave messages at (UK): 0727 844232; (US): 408 253 7199
- BUT I prefer to be contacted by e-mail
- AppleLink: SMITH.PG
- Internet: SMITH.PG@applelink.apple.com
-
- "SimpliFace" Sample code to accompany develop article
- on techniques for embedding scripts in applications.
-
-
- Ordered and un-ordered lists of long integers
-
- */
-
- #ifndef __LISTOFLONGS__
- #define __LISTOFLONGS__
-
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
-
-
-
-
- /**********************************************************************
- ** class TListOfLongs
- ** Sorted list of long integers (for un-ordered applications)
- ***********************************************************************/
-
- class TListOfLongs
- {
- public:
- TListOfLongs(void); // constructor
- TListOfLongs(const TListOfLongs&);
- ~TListOfLongs(void); // destructor
- TListOfLongs& operator=(const TListOfLongs&);
-
- Handle GetData(void); // saves data to handle
- void SetData(Handle h); // loads data from handle
-
- long CountElements(void);
- virtual OSErr InsertElement(long val);
- void DeleteElement(long val);
- long GetElement(long index);
- virtual long FindElement(long val); // returns index, or 0 if not found
-
- protected:
- long fNumItems;
- Handle fDataHandle;
-
- OSErr ExpandDataHandle(long numLongs);
- OSErr ShrinkDataHandle(long numLongs);
- };
-
-
-
- inline long TListOfLongs::CountElements(void)
- {
- return fNumItems;
- }
-
-
-
- /**********************************************************************
- ** class TOrderedListOfLongs
- ** Un-sorted list of long integers (for ordered applications)
- ***********************************************************************/
-
- class TOrderedListOfLongs : public TListOfLongs
- {
- public:
- TOrderedListOfLongs(void); // constructor
- TOrderedListOfLongs(const TListOfLongs&);
- ~TOrderedListOfLongs(void); // destructor
- TOrderedListOfLongs& operator=(const TOrderedListOfLongs&);
-
- virtual OSErr InsertElement(long val);
- OSErr InsertElementAt(long val, long index);
- virtual long FindElement(long val); // returns index, or 0 if not found
- };
-
-
- /**********************************************************************
- ** class TStackOfLongs
- ** Un-sorted stack of long integers (for ordered applications)
- ***********************************************************************/
-
- class TStackOfLongs : public TListOfLongs
- {
- public:
- TStackOfLongs(void); // constructor
- TStackOfLongs(const TListOfLongs&);
- ~TStackOfLongs(void); // destructor
- TStackOfLongs& operator=(const TStackOfLongs&);
-
- OSErr PushElement(long val);
- OSErr PopElement(long *val);
-
- // don't call these functions:
- virtual OSErr InsertElement(long val);
- virtual long FindElement(long val);
- };
-
-
- #endif
-